﻿using System.Configuration;

namespace xxpl1.HTTP.Runtime.Config
{
    public class HttpHandlerSection : ConfigurationSection
    {
        [ConfigurationProperty("HttpHandlers", IsDefaultCollection = true)]
        public HttpHandlerCollection HttpHandler
        {
            get { return (HttpHandlerCollection)base["HttpHandlers"]; }
        }
    }

    public class HttpHandlerCollection : ConfigurationElementCollection
    {
        protected override ConfigurationElement CreateNewElement()
        {
            return new HttpHandlerElement();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((HttpHandlerElement)element).Name;
        }
    }

    public class HttpHandlerElement : ConfigurationElement
    {
        [ConfigurationProperty("name", IsRequired = true)]
        public string Name
        {
            get { return (string)base["name"]; }
            set { base["name"] = value; }
        }

        [ConfigurationProperty("type", IsRequired = true)]
        public string Type
        {
            get { return (string)base["type"]; }
            set { base["type"] = value; }
        }
    }
}
